<template>
  <div>
    <el-table v-loading="loading" :data="purchaseOrderList" @row-click="handleRowClick">
      <el-table-column type="index" width="50" label="序号" />
      <el-table-column prop="poId" label="采购订单号" />
      <el-table-column prop="itemId" label="存货编码" />
      <el-table-column prop="itemName" label="存货名称" />
      <el-table-column prop="spec" label="规格型号" />
      <el-table-column prop="uom" label="计量单位" />
      <el-table-column prop="poNum" label="订单数量" />
      <el-table-column prop="payoffNum" label="未送料数量" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listPurchaseOrders } from "@/api/purchase/purchaseOrders";

export default {
  name: "PurchaseOrderSelect",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 采购订单表格数据
      purchaseOrderList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        poId: null
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 查询采购订单列表
    getList() {
      this.loading = true;
      listPurchaseOrders(this.queryParams).then(response => {
        this.purchaseOrderList = response.rows;
        console.log("查找采购订单"+this.purchaseOrderList);
        this.total = response.total;
        this.loading = false;
      });
    },
    // 搜索按钮操作
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置按钮操作
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 行点击事件
    handleRowClick(row) {
      this.$emit('select', row);
    }
  }
};
</script>
